package com.ymatou.iapi.csim.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.csim.parameter.DiscourseDto;
import com.ymatou.iapi.csim.parameter.FetchIndividualDiscourseByCategoryIdBean;
import com.ymatou.iapi.csim.parameter.SaveOrUpdateIndividualDiscourseBean;
import com.ymatou.iapi.csim.parameter.SaveOrUpdateIndividualDiscourseCategoryBean;
import com.ymatou.iapi.csim.service.FetchIndividualDiscourseByCategoryIdCall;
import com.ymatou.iapi.csim.service.SaveOrUpdateIndividualDiscourseCall;
import com.ymatou.iapi.csim.service.SaveOrUpdateIndividualDiscourseCategoryCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CsimCallService;
import com.ymttest.database.model.ymt_individualdiscourse;
import com.ymttest.database.sqlwapper.CSIM.ymt_individualdiscourseWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
/**
*通过分类获取个人话术列表
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_FetchIndividualDiscourseByCategoryId{
	private static FetchIndividualDiscourseByCategoryIdBean fetchindividualdiscoursebycategoryidBean;
	private static FetchIndividualDiscourseByCategoryIdCall fetchindividualdiscoursebycategoryidCall;
	private static ymt_individualdiscourseWapper individualdiscourseWapperWapper=new ymt_individualdiscourseWapper();
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("通过分类获取个人话术列表");
	}

	@Before
	public void caseUp() {
		fetchindividualdiscoursebycategoryidBean=new FetchIndividualDiscourseByCategoryIdBean();
		fetchindividualdiscoursebycategoryidCall=new FetchIndividualDiscourseByCategoryIdCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(fetchindividualdiscoursebycategoryidCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_FetchIndividualDiscourseByCategoryId_001() {
		Logger.start(true,"通过分类获取个人话术列表");
		try {
			SaveOrUpdateIndividualDiscourseBean saveorupdateindividualdiscourseBean=new SaveOrUpdateIndividualDiscourseBean();
			SaveOrUpdateIndividualDiscourseCall saveorupdateindividualdiscourseCall=new SaveOrUpdateIndividualDiscourseCall();
			saveorupdateindividualdiscourseBean.setId(TestDataManager.getRandomUUID().toString());
			saveorupdateindividualdiscourseBean.setCategoryId(TestDataManager.getRandomUUID().toString());
			saveorupdateindividualdiscourseBean.setTitle("自动化测试_"+TestDataManager.getRandomNum(5));
			saveorupdateindividualdiscourseBean.setSort(1);
			saveorupdateindividualdiscourseCall.setData(saveorupdateindividualdiscourseBean);
			saveorupdateindividualdiscourseCall.callService();
			
			fetchindividualdiscoursebycategoryidBean.setCategoryId(saveorupdateindividualdiscourseBean.getCategoryId());
			fetchindividualdiscoursebycategoryidCall.setData(fetchindividualdiscoursebycategoryidBean);
			fetchindividualdiscoursebycategoryidCall.callService();		
			
			ymt_individualdiscourse discourse=individualdiscourseWapperWapper.selectByPrimaryKey(saveorupdateindividualdiscourseBean.getId());
			//验证
			DiscourseDto disCall=fetchindividualdiscoursebycategoryidCall.getData().getResult().get(0);
			
			Logger.verifyEquals("200", fetchindividualdiscoursebycategoryidCall.getStatus(), "验证status");
			Logger.verifyEquals("", fetchindividualdiscoursebycategoryidCall.getMsg(), "验证Msg");
			Logger.verifyEquals(disCall.getId(), discourse.getId(), "验证Id");
			Logger.verifyEquals(disCall.getCategoryId(), discourse.getCategoryId(), "验证CategoryId");
			Logger.verifyEquals(disCall.getTitle(), discourse.getTitle(), "验证Title");
			Logger.verifyEquals(disCall.getCsId(),0, "验证CsId");
			Logger.verifyEquals(disCall.getSort(), discourse.getSort(), "验证Sort");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}